const INCOME_LIST = [
	{
		name: '5千以下',
		min: null,
		max: 5000
	},
	{
		name: '5千到1万',
		min: 5000,
		max: 10000,
	},
	{
		name: '1万-2万',
		min: 10000,
		max: 20000,
	},
	{
		name: '2万-3万',
		min: 20000,
		max: 30000,
	},
	{
		name: '3万-5万',
		min: 30000,
		max: 50000,
	},
	{
		name: '5万-10万',
		min: 50000,
		max: 100000,
	},
	{
		name: '10万以上',
		min: 100000,
		max: null,
	},
]


export const getIncomeList = ({ hasEmpty = true } = {}) => {
  const incomeList = [...INCOME_LIST];
  if (hasEmpty) {
    incomeList.push({
			name: '不限',
			min: null,
			max: null
		})
  }

  return incomeList
}

export const getHeightValueByIndex = ({ hasEmpty = true, index } = {}) => {
  const incomeList = getIncomeList({ hasEmpty });

	const value = incomeList[index];
	return [value.min, value.max]
}

const valueToText = (value) => {
	if(value / 10000 >= 1) {
		return `${parseInt(value/10000)}万`
	}

	return `${parseInt(value/1000)}千`
}

export const incomeToText = (min, max) => {
	if (!min && !max) {
		return ''
	}

	if (min && !max) {
		return `${valueToText(min)}以上`
	}

	if (!min && max) {
		return `${valueToText(max)}以下`
	}

	return `${valueToText(min)}-${valueToText(max)}`
}